package com.qc.bug.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.qc.bug.pojo.UserInfo;
import com.qc.bug.services.user.UserInfoServices;
import com.qc.bug.util.MyCons;

@Controller
@RequestMapping(value = "/userInfo")
public class UserInfoController {

	@Autowired
	private UserInfoServices userInfoBiz;

	/**
	 * @author admin
	 * @param phone
	 * @param pwd
	 * @param session
	 * @return String
	 * @time 2017 下午3:40:09
	 * @desc 用户登录
	 * 
	 */
	@RequestMapping(value = "/userLogin")
	public String findUserLogin(@RequestParam String phone, @RequestParam String pwd, HttpSession session) {

		UserInfo userInfo = userInfoBiz.findUserLogin(phone, pwd);
		if (null != userInfo) {// 登录成功
			session.setAttribute(MyCons.USRE_LOGIN, userInfo);
		}
		return "redirect:/jsp/index.jsp";
	}

	@RequestMapping(value = "/exit")
	public String updateExit(HttpSession session) {
		session.removeAttribute(MyCons.USRE_LOGIN);
		return "redirect:/jsp/index.js";
	}
}
